home *** CD-ROM | disk | FTP | other *** search
/ Acorn User: China / Acorn User China CD-ROM (UK) (Disc A) / Acorn User China CD-ROM (UK) (Disc A).bin / DEMON / BLOCKDRIVERS / BLOCKDRIVERS.ARC / Block9_Dox_BlockSpec < prev    next >
Encoding:
Text File  |  1994-03-23  |  13.1 KB  |  408 lines

  1. Block Driver Specification
  2. --------------------------
  3.  
  4. Hugo Fiennes, Rev 9, 6th March 1994
  5.  
  6. Contact me on 0749 670058 (altman@cryton.demon.co.uk, fidonet 2:255/102.0)
  7. for information about the latest version of the spec.
  8.  
  9. An application called !SerialDev holds the drivers - in your application !Run
  10. sequence you should check to see if <SerialDev$Path> is set, and if not, set
  11. it to your application directory, inside which is Modules.Internal at least,
  12. for your application to default to the internal port.
  13.  
  14. Eventually the idea is to have !SerialDev hold an application that handles
  15. the installation in a 'pretty way' - eg dragging new drivers to a window to
  16. install them, this would check to see if the driver was a later version of an
  17. existing driver and if so replace the old one, otherwise it would install the
  18. driver. Maybe this application could look a bit like ArtWorks !FontInst.
  19. Hint, hint, somebody write one...
  20.  
  21. The drivers each have their own directory just in case, possibly extensions
  22. with !Run files, modules, etc relating to the driver could be stored there.
  23. Of course, drivers know their own name and could load files into RMA on
  24. initialisation now and cause no problems.
  25.  
  26. ARCterm 7 1.44 and later use drivers of this specification. In this
  27. archive I have included some other drivers, documented below.
  28. Other programs that support block drivers are: Binkleyterm (2.11+),
  29. Hearsay 2 (2.17+), ARCfax (1.06+), ARCbbs (1.63+), RISCbbs (1.02+),
  30. Netway.
  31.  
  32. C headers have been provided for C programmers. BASIC/Assembler people
  33. should have no problems working it out either - a small application,
  34. 'Example' is provided which will work with any block driver module to
  35. provide a very simple terminal program.
  36.  
  37. REVISION 4 : Added 'wont empty' and 'dont overlay io' flags for pipes and
  38.              (unfixed) RO3.10 serial ports.
  39.  
  40. REVISION 5 : Intialise can now return an error string.
  41.  
  42. REVISION 6 : More information on calling initialise.
  43.  
  44. REVISION 7 : Pipe drivers now support 'peek byte' - return next byte in
  45.              buffer without removing it.
  46.  
  47. REVISION 8 : Internal port with PC cable now works with DCD low (bit 1
  48.              on SerialOp 0 now set). OSBYTE 152 used for peek byte
  49.              (for some reason the proper legal method doesn't work well).
  50.  
  51. REVISION 9 : All drivers must now store R14 on the stack so they can
  52.              be called from supervisor mode.
  53.  
  54. Internal driver
  55. ---------------
  56.  
  57. There are two version of this: Internal and InternalPC - the PC version
  58. expects a standard PC serial cable, which will only work properly on A5000
  59. or later machines (some early A5000s might have problems too).
  60.  
  61. Needs RO3.1 for block operations.
  62.  
  63. On a 'new hardware' machine (ie A5000 or later) will support 38400, 57600,
  64. 115200 automatically. Remember that these rates may well not be reliable
  65. due to the lack of FIFO on the serial chip. These rates are acheived by
  66. writing directly to the serial chip, which is defnitely not Acorn-approved.
  67. Beware!
  68.  
  69. Serial Port Dual Serial
  70. -----------------------
  71.  
  72. Again, there are 2 versions: SP_Dual and SP_DualPC, the PC version expects
  73. a standard PC serial cable.
  74.  
  75. PipeA and PipeB
  76. ---------------
  77.  
  78. This will autoload the ARCbbs_Pipes module (contained in the PipeA directory)
  79. if necessary.
  80.  
  81. The idea is, you open a port (0-15) on pipeA and data sent appears in the
  82. input of the corresponding port on pipeB (and vice-versa). DTR at one end
  83. is translated to DCD at the other (ditto for RTS-CTS). In this way, any
  84. application which supports the block driver spec can talk to another, for
  85. example, with ARCbbs and the ARCterm modem server on the same machine,
  86. some ARCbbs ports could be given over to network access via the modem
  87. server.
  88.  
  89. The pipes use the flag 'wont empty' as you can't wait for the pipe to
  90. 'finish sending' as the other end of the pipe may be waiting for the same
  91. thing (unlike a serial port, where the data will go away eventually).
  92.  
  93. The pipes are 2k long in each direction.
  94.  
  95. Acorn Telnet (Needs Acorn's TCP/IP protocol suite)
  96. ------------
  97. *Note! Does not store R14_SVC
  98.  
  99. This is only in testing, but is supplied as it might be useful. The coding
  100. is possibly quite inefficient, but it works. You require !Internet and 
  101. !Telnet to have been run before trying to use the driver. It will prompt
  102. for a host name - type one, or an internet address. You can add ',xx'
  103. where xx is the port number to telnet into. DCD as reported by modem
  104. status will go high when a sucessful connection is made. Dropping DTR
  105. then raising it again will clear any current call.
  106.  
  107. Known bugs: You can't have multiple sessions - if you load another emulator
  108. and run telnet the port_claim message will stop the first one - possibly a
  109. 'dynamic' port number (returned by init?) should be put into the spec to
  110. cater for things like this.
  111.  
  112.  
  113. Dummy (/dev/null)
  114. -----
  115.  
  116. This is a dummy driver, for when you want somewhere to trash data. It
  117. always shows CTS, DSR and DCD, and will completely ignore any data you
  118. send to it. It never has any data to give you.
  119.  
  120. II_Dual driver
  121. --------------
  122. *Note! Does not store R14_SVC
  123.  
  124. This is a temporary stop-gap until v3.xx software is available for the II
  125. card. The port number you specify is the II port number -1, ie II port 3
  126. would be specified as port 2. If you want to use the internal port while
  127. using II ports, you need the Internal2 driver. Both of these drivers
  128. rely on the poll entry being called directly after each wimp poll, to set
  129. the current port.
  130.  
  131. Econet driver (not supplied with this release)
  132. -------------
  133.  
  134. This works with ARCterm's new 16-line modem server to allow remote serial
  135. access. To support connection, etc, it has 3 special functions:
  136.  
  137. Connect (function code 128)
  138.   r1=handle/net/station (handle in bits 16-23,net in bits 8-15, station in 0-7)
  139.   r2-> password, null terminated
  140.  
  141.   Tries to set up a connection with the modem server. Returns 0 for success,
  142.   1 for no reply, 2 for already connected, or a pointer to an error block if
  143.   r0 is 'big' on return.
  144.  
  145. Disconnect (function code 129)
  146.   Disconnects from the modem server.
  147.  
  148. Scan for modem servers (function code 130)
  149.   r1=buffer to fill of format:
  150.      0    station
  151.      1    net
  152.      2    handle
  153.      3    modem driver number as defined in the modem server config file
  154.      4-63 modem ID string (null terminated)
  155.   r2=max number of entries table can handle
  156.  
  157. -------------------------------------------------------------------------------
  158. Driver layout
  159. -------------------------------------------------------------------------------
  160.  
  161. 0x000 Entry point to call routines
  162.  
  163.       In:  r0=function code
  164.            r1-r3=data
  165.  
  166.       Out: r0=result
  167.  
  168.       NOTE! CHANGE IN REVISION 9!
  169.       |
  170.       | This entry point can be called in EITHER user or supervisor mode, so
  171.       | R14 should always be pushed on the stack (STMFD R13!,{R14}) and be used
  172.       | to return from the driver so that r14_svc is preserved if the driver is
  173.       | called when in supervisor mode.
  174.       |
  175.  
  176.       r0-r3 can be corrupted, r4-r12 should be preserved. r14 contains the
  177.       return address
  178.  
  179.       Callers note that r13 should point to a full, descending stack
  180.       with a decent amount of space free on it.
  181.  
  182.       Example handler code follows:
  183.  
  184.       entry
  185.             STMFD R13!,{R14}
  186.             CMP   R0,#((endoftable-table)/4)
  187.             ADDCC PC,PC,R0,LSL#2
  188.             LDMFD R13!,{PC}
  189.  
  190.       table
  191.             B     func_0
  192.             B     func_1
  193.       endtable
  194.  
  195. 0x080 Driver information string (31 bytes max, 0 terminated)
  196. 0x0A0 Manufacturer information string (31 bytes max, 0 terminated)
  197. 0x0C0 Version number (top 16 bits major, low 16 bits minor)
  198. 0x0C4 Driver flags
  199.  
  200.       0x00000001 - More than one port availiable
  201.       0x00000002 - Supports split rates
  202.       0x00000004 - Has >1 byte hardware FIFO
  203.       0x00000008 - Can use Set control lines to generate a break
  204.       0x00000010 - Requires polling (by function 19)
  205.       0x00000020 - Won't empty (is a shared buffer)
  206.       0x00000040 - Supports block get/put operations
  207.       0x00000080 - Prefer not to overlap serial IO and disk IO
  208.  
  209.       0xdd...... - Top byte is highest port number supported (numbered from 0)
  210. 0x0C8 Driver number. This is allocated by me, and always has the lowest byte
  211.       as 0. The purpose of the driver number is for the Device_Claim protocol:
  212.       when a serial port is specified, the port number is used to specify
  213.       which port is to be claimed/released. The internal port is port 0 and
  214.       driver number 0. To make the port number to use you add the sub-port
  215.       number and the driver number together. eg, say the II dual card was
  216.       driver number 1 (0x00000100) and you wanted to claim port 5, you
  217.       would use the port number 0x00000105. This is unique and hopefully
  218.       would cause no problems.
  219.  
  220.       PORT NUMBERS PASSED TO BLOCK DRIVERS ARE THE LOWER 8 BITS ONLY: THEY DO
  221.       NOT INCLUDE THE DRIVER NUMBER.
  222.  
  223.       Currently allocated driver numbers:
  224.  
  225.         0 - Internal serial
  226.         1 - II dual serial
  227.         2 - Serial port dual serial
  228.         3 - Internal serial with PC cable
  229.         4 - Brainsoft Multipod (Kelvin Hill, #179 on Cryton)
  230.         5 - Acorn telnet interface
  231.         6 - Serial port dual serial with PC cable
  232.  
  233.       100 - Remote econet driver
  234.       128 - Virtual pipe (end A)
  235.       129 - Virtual pipe (end B)
  236.  
  237. 0x0CC - 0x0FF reserved
  238.  
  239. 0x100 Supported speed table. One word per speed, terminated with a null word.
  240.  
  241. 0x180-> driver code.
  242.  
  243. Function codes
  244. --------------
  245.  
  246. r0=0  Put byte
  247.       --------
  248.       r1=port number
  249.       r2=byte to send
  250.  
  251.       Returns with r0=-1 if byte not inserted, r0=0 if byte inserted into
  252.       TX queue.
  253.  
  254. r0=1  Get byte
  255.       --------
  256.       r1=port number
  257.  
  258.       Returns with r0=-1 if no byte availiable, r0=byte if a byte was removed.
  259.  
  260. r0=2  Put block
  261.       ---------
  262.       r1=port number
  263.       r2=pointer to block
  264.       r3=number of bytes to try and insert
  265.  
  266.       Returns with r0=number of bytes sucessfully inserted.
  267.  
  268. r0=3  Get block
  269.       ---------
  270.       r1=port number
  271.       r2=pointer to block
  272.       r3=maximum number of bytes to put into buffer
  273.  
  274.       Returns with r0=number of bytes put in buffer.
  275.  
  276. r0=4  Check TX buffer
  277.       ---------------
  278.       r1=port number
  279.  
  280.       Returns with r0=number of bytes free in TX buffer
  281.  
  282. r0=5  Check RX buffer
  283.       ---------------
  284.       r1=port number
  285.  
  286.       Returns with r0=number of bytes used in RX buffer
  287.  
  288. r0=6  Flush TX buffer (and hardware FIFO if applicable)
  289.       ---------------
  290.       r1=port number
  291.  
  292. r0=7  Flush RX buffer (and hardware FIFO if applicable)
  293.       ---------------
  294.       r1=port number
  295.  
  296. r0=8  Control lines
  297.       -------------
  298.       r1=port number
  299.       r2=-1 to read or new settings
  300.  
  301.       Returns r0=control line settings
  302.  
  303.       b0=DTR
  304.       b1=RTS
  305.       b2=If set, set TX data active (ie break state)
  306.  
  307. r0=9  Read modem control lines
  308.       ------------------------
  309.       r1=port number
  310.  
  311.       Returns r0=control line status
  312.  
  313.       b0=CTS
  314.       b1=DSR
  315.       b2=RI
  316.       b3=DCD
  317.  
  318. r0=10 Read RX errors
  319.       --------------
  320.       r1=port number
  321.  
  322.       Returns r0=bitset of errors seen since last read RX errors.
  323.  
  324.       b0=Overrun error
  325.       b1=Parity error
  326.       b2=Framing error
  327.       b3=Break received
  328.  
  329. r0=11 Send break
  330.       ----------
  331.       r1=port number
  332.       r2=break time (in centiseconds)
  333.  
  334.       This does not return until the break has been sent - although some
  335.       serial ports could multitask when sending a break, the internal port
  336.       can't. Check the driver flags to see if you can use a multitasking
  337.       break before using this call.
  338.  
  339. r0=12 Examine byte (like Get byte but leaves it in the buffer)
  340.       ------------
  341.       r1=port number
  342.  
  343.       Returns with r0=-1 if no byte availiable, r0=byte if a byte was
  344.       returned.
  345.  
  346. r0=13 TX Speed
  347.       --------
  348.       r1=port number
  349.       r2=speed to set or -1 to read
  350.  
  351.       Returns with r0=speed.
  352.  
  353. r0=14 RX Speed
  354.       --------
  355.       r1=port number
  356.       r2=speed to set or -1 to read
  357.  
  358.       Returns with r0=speed.
  359.  
  360. r0=15 Set word format
  361.       ---------------
  362.       r1=port number
  363.       r2=word format to set or -1 to read
  364.  
  365.       Returns with r0=word format.
  366.  
  367. r0=16 Set flow control
  368.       ----------------
  369.       r1=port number
  370.       r2=flow control method to set or -1 to read
  371.  
  372.       Returns with r0=method
  373.  
  374.       0=no flow control
  375.       1=hardware
  376.       2=xon/xoff
  377.       3=both
  378.  
  379. r0=17 Initialise driver
  380.       -----------------
  381.       r1=port number
  382.       r2=parameter string (optional)
  383.  
  384.       r2 optionally points to a null terminated string which can specify
  385.       device options.
  386.  
  387.       Returns with r0 pointing to error string if
  388.       initialisation unsucessful, otherwise r0=0.
  389.  
  390.       NOTE! Do not read the baud rate tables or driver flags UNTIL AFTER
  391.       the intialise driver entry has been called. This allows for drivers
  392.       to configure themselves to the available hardware and adjust the
  393.       services offered accordingly.
  394.  
  395. r0=18 Close down driver
  396.       -----------------
  397.       r1=port number
  398.  
  399. r0=19 Poll driver
  400.       -----------
  401.       r1=port number
  402.  
  403.       This should be called regularly (eg in a polling loop) for the driver
  404.       to perform polling tasks - eg the econet driver needs to check internal
  405.       buffers and poll econet protocol tasks. Polls can be as infrequent as
  406.       three or four times a second : if a driver needs polling more often
  407.       than that, it should install a module and hook onto a vector somewhere.
  408.